Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rush-migrate-subspace-plugin]: add clean subspace feature #22

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

pedro-gomes-92
Copy link
Collaborator

@pedro-gomes-92 pedro-gomes-92 commented Nov 29, 2024

Basic Checks

Have you run rush change for this change?

  • Yes
  • No

If No, please run rush change before, this is necessary.

If adding a new feature, the PR's description includes:

Reason for adding this feature

A lot of subspaces are not being properly managed, where there are a lot of similar, duplicated or unused dependency versions being added to the "common-versions.json". Adding this feature helps developers to rapidly clean their subspace multiple dependency versions, reducing its "pnpm-lock.yaml" file and minimise future issues.

How to use

rush migrate-subspace --clean

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Summary

Supports the parameter --clean, to remove a subspace unnecessary dependency versions, reducing its "pnpm-lock.yaml" file and prevent future dependency issues.

Detail

  • Removes duplicated dependency versions from "common-versions.json" alternativeAllowedVersions
  • Removes unused dependency versions from "common-versions.json" alternativeAllowedVersions
  • Removes duplicated dependency versions from "package.json" between devDependencies and dependencies
  • Removes superset dependencies from "common-versions.json" alternativeAllowedVersions and updates each proper project "package.json" with the new subset version (e.g. Project P1 contains A@^1.0.0 and Project P2 contains [email protected], the script will remove ^1.0.0 from the "common-versions.json" and update P1 "package.json" to [email protected])

@pedro-gomes-92 pedro-gomes-92 force-pushed the pedrogomes/support-clean-subspace branch from c0eb143 to aeaa914 Compare December 19, 2024 07:20
@pedro-gomes-92 pedro-gomes-92 marked this pull request as ready for review December 20, 2024 04:30
@pedro-gomes-92 pedro-gomes-92 self-assigned this Dec 20, 2024
@pedro-gomes-92 pedro-gomes-92 changed the title feat: start clean [rush-migrate-subspace-plugin]: add clean subspace feature Dec 20, 2024
const devDependencies: string[] = Object.keys(projectPackageJson.devDependencies || {});

devDependencies.forEach((devDependency) => {
if (dependencies.includes(devDependency)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is valid to declare something like this:

   "dependencies": {
      "thing": "^1.0.0"  // people who install my project can use the latest 1.x
   },
   "devDependencies": {
      "thing": "1.2.3" // but for development, I want the specific version 1.2.3
   },

Copy link
Collaborator Author

@pedro-gomes-92 pedro-gomes-92 Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@octogonz I understand your point, but for the sake of cleaning a subspace dependency tree, don't you think it is more beneficial for a package to keep 1 standard version instead of multiple possible versions?
In other words, what is the benefit for developers and users to use 2 different versions of "thing", which can lead to different results (and even issues that might not be tracked during development)?

Copy link
Member

@octogonz octogonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with some suggestions

@pedro-gomes-92 pedro-gomes-92 force-pushed the pedrogomes/support-clean-subspace branch from 82ee097 to b372387 Compare December 20, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants